<script>


import {mapMutations, mapState} from "vuex";

export default {
  name: "Nav",
  methods: {
    ...mapMutations(['addTabs']),
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    toBasic(value) {
      if (this.$route.path !== value.url) {
        this.$router.replace(value.url)
      }
    }
  },
    computed: {
      ...mapState([ 'editableTabs', "authTabs"])
    },
}
</script>

<template>
  <el-row class="tac">
    <el-col :span="24">
      <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">
        <el-submenu :index="item.level" v-for="item in authTabs" :key="item.level">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>{{item.tabName}}</span>
          </template>
          <el-menu-item-group>
            <el-submenu :index="tab.level" v-for="tab in item.tabList" :key="tab.level">
              <template slot="title">
                <span>{{tab.tabName}}</span>
              </template>
              <el-menu-item-group>
             <el-menu-item
                 v-for="url in tab.tabList"
                 :key="url.level"
                 :index="url.level" @click="toBasic(url)"
             >
               {{url.tabName}}
             </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-col>
  </el-row>
</template>

<style scoped>

</style>
